﻿#region 命名空间

using System;
using WinnerCMS.BLL;
using WinnerCMS.Common;
using WinnerCMS.Model;
using WinnerCMS.WebFactory;

#endregion

namespace WinnerCMS.WebUI
{
    public partial class ApplyFriend : ClientPublicPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var config = CMSConfig.Instance();
                if (config.Friend.PublicReg == false)
                {
                    btnAdd.Enabled = false;
                    MsgBox.Alert("管理员已经关闭链接申请！", this);
                }
                else
                {
                    btnAdd.Enabled = true;
                }
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (PostData.PostFormRight() == false)
            {
                MsgBox.Alert("非法数据来源。", this);
                SecurityCenterManage.AppErr("添加友情链接数据来源非法。");
                return;
            }

            var model = new FriendLink();
            model.Title = txtTitle.Text.Trim();
            model.Logo = txtLogo.Text.Trim();
            model.Url = txtURL.Text.Trim();
            model.Pass = false;

            new FriendLinkManage().Add(model, UpdatePanel1);
            MsgBox.Alert("添加成功！等待管理员审核。", this);
        }
    }
}